package com.hh.goodsmanage.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hh.baseframework.util.Check;
import com.hh.baseframework.util.dto.PageRange;
import com.hh.goodsmanage.bean.Goodsmanage;
import com.hh.goodsmanage.bean.GoodsmanageIn;
import com.hh.hibernate.util.dto.PagingData;
import com.hh.system.service.impl.BaseService;

@Service
public class GoodsmanageInService extends BaseService<GoodsmanageIn> {

	@Autowired
	private GoodsmanageService goodsmanageService;

	@Override
	public PagingData<GoodsmanageIn> queryPagingData(GoodsmanageIn entity,
			PageRange pageRange) {
		PagingData<GoodsmanageIn> result = super.queryPagingData(entity,
				pageRange);
		List<GoodsmanageIn> goodsmanageIns = result.getItems();
		for (GoodsmanageIn goodsmanageIn : goodsmanageIns) {
			if (Check.isNoEmpty(goodsmanageIn.getGoodsmanageId())) {
				Goodsmanage goodsmanage = goodsmanageService
						.findObjectById(goodsmanageIn.getGoodsmanageId());
				if (goodsmanage != null) {
					goodsmanageIn.setGoodsmanageId(goodsmanage.getName() + "（"
							+ goodsmanage.getCode() + "）");
				}
			}
		}
		return result;
	}

}